<template>
	<view class="bill">
		<view class="yf-form">
			<text class="label">订单编号</text>
			<input disabled="disabled" v-model="bill.orderNo" class="inp" type="text" placeholder="订单编号">
		</view>
		<view class="yf-form">
			<text class="label">实付金额</text>
			<input disabled="disabled" v-model="bill.amount" class="inp" type="text" placeholder="实付金额">
		</view>
		<view class="yf-form">
			<text class="label">抬头</text>
			<input v-model="bill.company" class="inp" type="text" placeholder="公司抬头">
		</view>
		<view class="yf-form">
			<text class="label">税号</text>
			<input v-model="bill.number" class="inp" type="text" placeholder="税号">
		</view>
		
		<view class="yf-form">
			<text class="label">邮箱</text>
			<input v-model="bill.mail" class="inp" type="text" placeholder="税号">
		</view>
	
		<view class="btn" v-if="bill.status!=1" @click="update">
			保存
		</view>
		<view class="btn" style="color: gray;" v-else>
			已开票
		</view>
	</view>
</template>

<script>
	import {getBill,merge} from '@/api/bill'
	import {showCorrect} from '@/modal'
	export default {
		onShow() {
		   this.orderNo = this.$Route.query.orderNo
		   this.amount = this.$Route.query.amount
		   getBill(this.orderNo).then(res=>{
			   if(res.data){
				     this.bill = res.data
			   }else{
				   this.bill.orderNo = this.orderNo
				   this.bill.amount = this.amount
			   }
			 
		   })
		},
		data() {
			return {
				orderNo:null,
				bill:{
					orderNo:null,
					company:null,
					mail:null,
					number:null
				}
			};
		},
		methods:{
			update(){
				merge(this.bill).then(res=>{
					showCorrect('操作成功!').then(res=>{
						this.$Router.back()
					})
				})
			}
		}
	}
</script>

<style lang="stylus">
	.yf-form
		border-bottom 1px solid #DCDCDC
		height 105upx
		background-color white
		display flex
		align-items center
		padding 0 30upx
		.label
				min-width 120upx
				color #6F6F6F
				font-size 28upx
				margin-right 40upx
		.inp
			width 100%
			font-size 28upx
			color #A1A1A1
	.btn
		position absolute
		bottom 20upx
		left 20upx
		right 20upx
		height:80upx;
		background:#F7895E
		border-radius:30px
		color #FFFFFF
		font-size 28upx
		display flex
		align-items center
		justify-content center
		margin-top 23upx
</style>
